// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Handler for all civil
// -----------------------------------------------	

private ["_group"];

_group = _this select 0;

{
	wcgarbage = [_x, wcskill] spawn WC_fnc_setskill;

	_x addEventHandler ["HandleDamage", {
		if !((_this select 0) == (_this select 3)) then {
			(_this select 0) setDamage (0.5 + (random 0.5));
		};
	}];

	_x addEventHandler ["Killed", {
		wcgarbage = _this spawn WC_fnc_garbagecollector;
		if ((name (_this select 1)) in wcinteam) then {
			wcnumberofkilledofmissionC = wcnumberofkilledofmissionC + 1;
			wccivilkilled =  wccivilkilled + 1;
			["wccivilkilled", "client"] call WC_fnc_publicvariable;
			wcfame = (wcfame - random 0.1);
		};
	}];

	_x addEventHandler ["FiredNear", {
		(_this select 0) playMove 'AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon';
		(_this select 0) stop true;
	}];

	// Unlimited ammo for civilians
	if !((typeOf _x) in wccivilwithoutweapons) then {
		_x addEventHandler ["Fired", {(_this select 0) setVehicleAmmo 1;}];
	};
	sleep 0.1;
} foreach (units _group);